package com.designpattern.DecoratorPattern;

/**
 * @Author yp
 * @Date 2021-05-24
 * @Description  抽象装饰者
 **/

public abstract class Decorator implements Person {

    protected Person person;

    public void setPerson(Person person){
        this.person = person;
    }

    @Override
    public void eat(){
        person.eat();
    }
}


/**
 * @Author yp
 * @Date 2021-05-24
 * @Description 具体装饰者A
 **/
class ManDecoratorA extends Decorator {

    public void eat(){
        super.eat();
        reEat();
        System.out.println("ManDecoratorA类。。");
    }

    public void reEat(){
        System.out.println("A再吃一顿！(具体装饰者)");
    }
}


/**
 * @Author yp
 * @Date 2021-05-24
 * @Description 具体装饰者B
 **/
class ManDecoratorB extends Decorator {

    public void eat(){
        super.eat();
        reEat();
    }

    public void reEat(){
        System.out.println("B再吃一顿！(具体装饰者)");
    }
}